package com.example.administrator.u17.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.u17.R;
import com.example.administrator.u17.adapter.ShouCangAdapter;

import org.xutils.DbManager;
import org.xutils.x;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/11/16.
 */

public class ShouCangFragment extends Fragment{

    private ImageView iv;
    private TextView tv;
    private GridView gridView;
//    private List<> list;
    private ShouCangAdapter adapter;
    private DbManager db;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=View.inflate(getActivity(), R.layout.fragment_shoucang,null);
        initView(view);
        initData();
        setData();
        return view;
    }

    private void setData() {
        gridView.setAdapter(adapter);
    }

    private void initData() {
//        list=new ArrayList();
//        list.addAll(db.selector().findAll());
//        adapter=new ShouCangAdapter(getActivity(),list);
        db = x.getDb(new DbManager.DaoConfig());
    }

    private void initView(View view) {
        iv=(ImageView)view.findViewById(R.id.iv_fragment_shoucang);
        tv=(TextView)view.findViewById(R.id.tv_fragment_shoucang);
        gridView=(GridView)view.findViewById(R.id.gv_fragment_shoucang);
    }
}
